const path=require('path');
const webpack=require('webpack');
const HtmlwebpackPlugin=require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports={
    mode:'production',
    entry:{
        'index':['./src/index.jsx']
    },
    output:{
        filename:'[name].[hash].js',
        path:path.resolve(__dirname,'../dist')
    },
    resolve:{
        extensions:['.js','.jsx'],
        alias:{
            '@':path.resolve('./src')
        }
    },
    optimization:{
        minimize:false
    },
    module:{
        rules:[
            {
                test:/\.js|jsx$/,
                use:['babel-loader'],
                include:[path.resolve(__dirname,'../src/index.js'),path.resolve(__dirname,'../src')]
            },
            {
                test:/\.css$/,
                use:ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: "css-loader"
                })
            }
        ]
    },
    plugins:[
        new webpack.NoEmitOnErrorsPlugin(),
        new HtmlwebpackPlugin({
            filename:'index.html',
            template:'./src/index.html',
            inject:true
        }),
        new ExtractTextPlugin({
            filename:'./dist/[name].[hash].css'
        })
    ]
}